package com.becca.cake.model.voucher;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.becca.cake.core.exception.ServiceException;

/**
 * 抵用券实体
 * @copyright  尊星(上海)信息科技有限公司
 * @author Mouwanming
 * @date 2016年9月6日 上午11:15:17
 */
public class VoucherModel implements Serializable{

	/**
	 * 
	 */
	public static final long serialVersionUID = -8291232693990481221L;
	/**抵用券状态(1:已上架)*/
	public static final Byte VOUCHER_STATUS_ALREADY  = 1 ;
	/**抵用券状态(0:未上架)*/
	public static final Byte VOUCHER_STATUS_NOT_ALREADY = 0 ;
	/**抵用券状态(2:已下架)*/
	public static final Byte VOUCHER_STATUS_DOWN  = 2 ;
	/**抵用券编号不能为空*/
	public static final String VOUCHER_ID_NULL = "抵用券编号不能为空";
	/**抵用券名称不能为空*/
	public static final String VOUCHER_NAME_NULL = "抵用券名称不能为空";
	/**抵用券市场价不能为空*/
	public static final String VOUCHER_MARKET_PRICE_NULL = "抵用券市场价不能为空";
	/**抵用券销售价不能为空*/
	public static final String VOUCHER_SELL_PRICE_NULL = "抵用券销售价不能为空";
	/**抵用券有效天不能为空*/
	public static final String VOUCHER_EFFICIENT_DAY_NULL = "抵用券有效天不能为空";
	/**抵用券编号*/
	public static final String VOUCHER_ORDER_NULL = "抵用券排序不能为空";
	/**抵用券信息不存在*/
    public static final String VOUCHER_NOT_EXISTS = "抵用券信息不存在";
    /**该商品已下架*/
    public static final String VOUCHER_STATUS_DOWN_EXIST = "该抵用券已下架";
	/**抵用券编号*/
	private Integer id;
	/**抵用券名称*/
	private String voucherName;
	/**抵用券市场价*/
	private String voucherMarketPrice;
	/**抵用券销售价*/
	private String voucherSellPrice;
	/**抵用券有效天数*/    
    private Integer effectiveDays;
    /**抵用券状态(0:未上架 1:已上架  2:已下架)*/
    private Byte    voucherStatus;
	/**抵用券排序*/
    private Integer voucherOrder;
    /**创建时间*/
    private Date    createdDate;
    /**创建人*/
    private String  createdName;
    /**修改时间*/
    private Date    updatedDate;
    /**修改人*/
    private String  updatedName;
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getVoucherName() {
		return voucherName;
	}
	public void setVoucherName(String voucherName) {
		this.voucherName = voucherName;
	}
	public String getVoucherMarketPrice() {
		return voucherMarketPrice;
	}
	public void setVoucherMarketPrice(String voucherMarketPrice) {
		this.voucherMarketPrice = voucherMarketPrice;
	}
	public String getVoucherSellPrice() {
		return voucherSellPrice;
	}
	public void setVoucherSellPrice(String voucherSellPrice) {
		this.voucherSellPrice = voucherSellPrice;
	}
	public Integer getEffectiveDays() {
		return effectiveDays;
	}
	public void setEffectiveDays(Integer effectiveDays) {
		this.effectiveDays = effectiveDays;
	}
	public Integer getVoucherOrder() {
		return voucherOrder;
	}
	public void setVoucherOrder(Integer voucherOrder) {
		this.voucherOrder = voucherOrder;
	}
	public Date getCreatedDate() {
		return createdDate;
	}
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	public String getCreatedName() {
		return createdName;
	}
	public void setCreatedName(String createdName) {
		this.createdName = createdName;
	}
	public Date getUpdatedDate() {
		return updatedDate;
	}
	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	public String getUpdatedName() {
		return updatedName;
	}
	public void setUpdatedName(String updatedName) {
		this.updatedName = updatedName;
	}
	
	
	
	public Byte getVoucherStatus() {
		return voucherStatus;
	}
	public void setVoucherStatus(Byte voucherStatus) {
		this.voucherStatus = voucherStatus;
	}
	/**
	 * 检验抵用券ID是否为空
	 * @param voucherId
	 */
	public static void validVoucherIdNull(Integer voucherId){
		if(voucherId == null){
			throw new ServiceException(VoucherModel.VOUCHER_ID_NULL);
		}
	}
	
	/**
     * 校验抵用券排序
     * @param list
     */
    public static void validVoucherOrder(List<VoucherModel> list) {
        for (VoucherModel voucherModel : list) {
            if (voucherModel.getVoucherOrder() == null) {
                throw new ServiceException(VoucherModel.VOUCHER_ORDER_NULL);
            }
            if (voucherModel.getId() == null) {
                throw new ServiceException(VoucherModel.VOUCHER_ID_NULL);
            }
        }
    }

    @Override
    public String toString() {
        return "GoodsDO [id=" + id + ", voucherName=" + voucherName + ", voucherMarketPrice=" + voucherMarketPrice
               + ", voucherSellPrice=" + voucherSellPrice + ", effectiveDays=" + effectiveDays + ", voucherStatus=" + voucherStatus + ",voucherOrder="
               + voucherOrder + ", createdDate=" + createdDate + ", createdName="
               + createdName + ", updatedDate=" + updatedDate + ", updatedName=" + updatedName
               + "]";
    }
	

}
